Ext.define('AM.view.window.Tools', {
    extend: 'Ext.window.Window',
    alias : 'widget.tools',
    stores: ['StoreColor'],
    title : 'Edit Color Tip',
    layout: 'fit',
    autoShow: true,
    modal : true,
        
    initComponent: function() {
        this.items = [
            {
                xtype: 'form',
                bodyPadding: '5px,5px,5px,5px',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [{
                    	xtype:'tip',
                    	id:'toolstip',
                    	//editable : true,
                    	labelWidth : 30
                 	   
                    },{
                    	 xtype: 'fieldset',
                         title: 'Select Color',
                         collapsible: true,
//                         collapsed: true,
                         items: [{
	                        xtype: 'colorpicker',
	                        margin :'5 0 0 15',
	                        colors : ['009933','006699','00FFCC','0099FF','339900','33CC66','3366CC','33FFFF','993333','B8B8B8',
	                                  '9966CC','9999FF','CCCC00','CC9999','CC66FF','FF9900','FF6666','FF99CC','FF99FF','CC00FF',
	                                  'FFFF66','E80000','FFFFFF'
	                                  ],
	                        listeners: {
	                            select: function(picker, selColor) {
	                            	st = Ext.getStore('StoreColor');
	                            	it =st.findExact('task', selColor);
	                            	tt = Ext.getStore('StoreComboTip');
	                            	idd = Ext.getCmp('toolstip').getValue();
	                            	id = tt.findExact('id', idd);
	                            	y = it + 1;
	                            	tt.getAt(id).set('it', y);
	                            	u = 'ext-toolscolor-' + y;
	                            	Ext.getCmp('toolstip').setColor(u);
	                            	Ext.Ajax.request({
                                        url: 'data/tools.php',
                                        scope: this,
                                        method: "GET",
                                        params: {
                                            storeTip: 'color',
                                            acction: 'color',
                                            id: idd,
                                            it: it+1,
                                            UserID: UserID
                                        },
                                        success: function(response){
                                        }
                                    });
	                            }
	                        }
	                    }]
                    }
                ]
            }
        ];

        this.buttons = [
            {
                text: '<b>Aplica</b>',
                iconCls: "btn-save",
                scope: this,
                handler: this.Color
            },{
                text: 'Cancel',
                scope: this,
                handler: this.close
            }
        ];

        this.callParent(arguments);
    },
    Color: function (obj,e) {
    	Ext.getCmp('userlist').getStore().load({
    		params: {storeTip: 'grid', acction : 'dateout', UserID: UserID}});
    	this.close();
    }
});